package com.imooc.common.strategy;

import org.nutz.json.Json;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class ManagerStrategy {

    private static Map<String,String> strategyMap = new HashMap<>();

    public static void excuteStrategy(String type){

        for (RefelDbTypeEnum t : RefelDbTypeEnum.values()) {
            strategyMap.put(t.type(),t.clazz());
        }

        String class_path = strategyMap.get(type);

        try {
            Class clazz = Class.forName(class_path);
            Method excute = clazz.getDeclaredMethod("excute");
            Object invoke = excute.invoke(clazz.newInstance());
            System.out.println(Json.toJson(invoke));
        }catch (Exception e){
            e.printStackTrace();
        }

    }



}
